var app = getApp()
var IP = app.globalData.IP
Page({
  data: {
    category: [{
        categoryid: 1,
        categoryname: '家电维修',
      },
      {
        categoryid: 2,
        categoryname: '水电维修',
      },
      {
        categoryid: 3,
        categoryname: '管道疏通'
      },
      {
        categoryid: 4,
        categoryname: '家电回收'
      }

    ],
    curNav: 1,
    curIndex: 0,
    serviceList: [],
  },

  getservicelistbycategory() {
    // 1家电类 2水电类 3 管道类 4家电回收类
    wx.request({
      url: `http://${IP}:8080/service/getservicelistbycategory/` + this.data.curNav,
      success: res => {
        this.setData({
          serviceList: res.data
        })
      }
    })
  },
  switchRightTab: function (e) {
    let id = e.target.dataset.id,
      index = e.target.dataset.index;
    this.setData({
      curNav: id,
      curIndex: index
    })
    this.getservicelistbycategory()


  },


  onLoad(options) {

  },
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

    var id = app.globalData.curNav
    var index = app.globalData.curIndex
    this.setData({
      curNav: id,
      curIndex: index
    })
    this.getservicelistbycategory()
    // app.globalData.curNav =1
    // app.globalData.curIndex =0



  },


})